<template>
    <div>
        <h1>排房增加</h1>
        <table class="table table-success">
            <tbody>
                <tr>
                    <td>房型:
                    <input type="text" v-model="info.name" /></td>
                </tr>
                <tr>
                    <td>未排:
                    <input type="text" v-model="info.wei" /></td>
                </tr>
                <tr>
                    <td>已排:<input type="text" v-model="info.yi" /></td>
                </tr>
                <tr>
                    <td>选择房号:
                        <input type="radio" v-model="info.state" name="state" value="1" />101
                        <input type="radio" v-model="info.state" name="state" value="0"/>102
                    </td>
                </tr>
                <tr>
                    <td><input type="button"  class="btn btn-success" value="确认" @click="ok"/></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import { onMounted,reactive,ref } from 'vue';
import { useRoute,useRouter } from 'vue-router';
import axios from 'axios';

const route=useRoute();
const router=useRouter();

const info=reactive({
    id:route.query.xid,
    name:'',
    wei:'',
    yi:'',
    state:1
})
//反填
const FanTian=()=>{
    axios({
        url:'/api/RoomP/FanTian',
        method:'get',
        data:{
            id:route.query.xid
        }
    })
    .then(res=>{
        console.log(res);
        info.name=res.data.name;
        info.wei=res.data.wei;
        info.yi=res.data.yi;
        info.state=res.data.state;
    })
}

const ok=()=>{
    axios({
        url:'/api/RoomP/Update',
        method:'put',
        data:info
    })
    .then(res=>{
        console.log(res);
        if(res.data>0){
            alert('修改确认成功!');
            router.push('/RoomPList');
        }
        else{
            alert('修改确认失败!');
        }
    })
}

</script>